package page;

import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.Version;

public class Main {
	Configuration cfg = new Configuration(new Version(2, 3, 0));
	{
		cfg.setClassForTemplateLoading(Main.class, "/");
		cfg.setDefaultEncoding("utf-8");
	}

	private void save(Map<String, String> data, String templatePath) throws Exception {
		Writer w = new OutputStreamWriter(System.out);
		Template template = cfg.getTemplate(templatePath);
		template.process(data, w);
	}

	public static void main(String[] args) throws Exception {
		Map<String, String> map =new HashMap<String, String>();
		map.put("title", "这个歌title");
		map.put("content", "这个content");
		new Main().save(map,"template/admin-controllers.ftl");
	}
}
